#!/usr/bin/env python

import tables

import charmicat

fp = tables.openFile("./ypi0pi0_pi0.h5")
nt = fp.root.nt

cuts = {
    'mass_cut': "sqrt((mass - 0.135)**2) < 0.0054*3",
    'g0e_cut': 'g0energy > 0.1',
    'g1e_cut': 'g1energy > 0.1',
    'g0e9oe25_cut': 'g0e9oe25 > 0.95',
    'g1e9oe25_cut': 'g1e9oe25 > 0.95',
    }

seq = 'mass_cut g0e_cut g1e_cut g0e9oe25_cut g1e9oe25_cut'.split()

for i, cut in enumerate(charmicat.utils.cut_accumulate([cuts[k] for k in seq])):
#    print cut
    print "{0}/{1} events pass for".format(len(nt.readWhere(cut, field='eventno')), len(nt)), " + ".join(seq[:i+1])


